/**
 * Created by zhangguoyu on 16/4/16.
 */

var ModelBuilder = require('./ModelBuilder');
var Utils = require('../utils/Utils');

var Model = function () {};

Model.prototype.create = function (name, schema, indexs, managerClass) {
  if (Utils.isFunction(indexs)) {
    managerClass = indexs;
    indexs = {};
  }
  var modelBuilder = new ModelBuilder(name)
    .schema(schema);
  if (indexs) {
    modelBuilder.indexs(indexs);
  }
  if (managerClass) {
    modelBuilder.manager(managerClass);
  }
  return modelBuilder.create();
};

module.exports = exports = new Model();